﻿// This function creates a standard table with column/rows
// Parameter Information
// objArray = Anytype of object array, like JSON results
// theme (optional) = A css class to add to the table (e.g. <table class="<theme>">
// enableHeader (optional) = Controls if you want to hide/show, default is show
function createGrid(objArray,path) {
	var str="";
	try{
	    var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
	    str+='<a onclick="addFolder(\''+path+'\')" href="#">新建文件夹</a>|\
			  <a href="#" onclick="upload();">上传资源</a>|';
	    str+='<a onclick="dash(\''+path+'\')" href="#">回收站</a>';
	    if(path!='a-1'){
	    	var path1=path.substring(0,path.lastIndexOf('a'));
	    	str+='|<a href="#" onclick="request(\'a-1\')">资源首页</a>|\
	    	 <a href="#" onclick="request(\''+path1+'\')">返回上一级</a>';  
	    }
	    
	    str+='<br/>';
	    str+='<table><tbody><tr>';
	    for (var i = 0; i < array.length; i++) {
	    	var item=array[i];
	    	if(item.type==4){
	    		str+='<td align="center">\
	    			<p><a href="#" onclick="request(\''+path+'a'+item.rid+'\')">\
					<img id="img_type" src="../../static/img/file_type/folder.png"  >\
					</a></p>\
					<p id="'+item.rid+'_name"> '+item.name+'</p>\
					<p id="foper" style="overflow:hidden;">\
					<a href="#" onclick="rename1(\''+item.rid+'\',\''+item.pid+'\')">重命名</a>|\
					<a href="#" onclick="del(\''+item.rid+'\',\''+item.type+'\',\''+item.path+'\')">删除</a>';
			
	    	}else{
	    		str+='<td>\
					<a href="#" onclick="show_resource(\''+item.rid+'\')">\
					<img id="img_type" src="../../static/img/file_type/word.png" align="left" >\
					</a>\
					名称： '+item.name+'<br/>\
					大小：'+item.size+'<br/>\
					 类别：程序文档<br/> \
	    			上传者：'+item.owner+'<br/>\
					<a href="/resource/resource_show.do?rid='+item.rid+'"><font color="green">进入下载页面</font></a>\
				</td>';
	    	}
	    	if((i+1)%4==0){
	    		str+='</tr><tr>';
	    	}
	    }
	
		str+='</tr></tbody></table>';
	}catch(error){
		alert(error);
	}
    return str;
}





